package xj.meta;

public class Link implements Cloneable {

  public Link(String name, String link) {
    this.name = name;
    this.link = link;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getLink() {
    return link;
  }

  public void setLink(String link) {
    this.link = link;
  }

  public String getDocument() {
    if (link != null) {
      int i = link.indexOf('#');
      if (i >= 0) {
	return link.substring(0, i);
      } else {
	return link;
      }
    }
    return null;
  }

  public String getRefid() {
    if (link != null) {
      int i = link.indexOf('#');
      if (i >= 0) {
	return link.substring(i + 1);
      }
    }
    return null;
  }

  @Override
  public Object clone() throws CloneNotSupportedException {
    Link l = (Link) super.clone();
    l.name = name;
    l.link = link;
    return l;
  }

  protected String name;

  protected String link;

}
